package com.lixl.concurrent.thread;

public class Police {
	
	public static byte[] lock = null;
	
	public static byte[] getLock(){
		if(lock==null){
			lock = new byte[0];
		}
		return lock;
	}
	
	/**
	 * WAITING
	 * @param lock
	 */
	public static void syncWait(Car car, byte[] lock){
		synchronized (lock) {
			System.out.println(car.getName()+"\t"+car.driver+" 进入waiting状态");
			try {
				lock.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(car.getName()+"\t"+car.driver+" 退出waiting状态");
		}
	}
	
	/**
	 * 唤醒WAITING状态的线程
	 */
	public static void syncNotify(byte[] lock){
		
		synchronized (lock) {
			lock.notifyAll();
		}
		
	}
}
